﻿@model KlubSportowy.dbEntities

@{
    ViewBag.Title = "Mój profil";
    var jTableStyle = "metro/blue/jtable.css";
    if (!string.IsNullOrEmpty(Request["jTableStyle"]))
    {
        jTableStyle = Request["jTableStyle"];
    }
}


<link href="@Url.Content("~/Content/jquery-ui-1.10.0.custom.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Scripts/jtable/themes/" + jTableStyle)" rel="stylesheet" type="text/css" />

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>


@if (User.IsInRole("Administratorzy"))
{

<div class="col_w960_alone">
<h2>Administracja</h2>
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs">
	<ul role="tablist" class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
		<li aria-selected="false" aria-labelledby="ui-id-2" aria-controls="tabs-1" tabindex="-1" role="tab" class="ui-state-default ui-corner-top"><a id="ui-id-2" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#events">Zajęcia i zawody</a></li>
		<li aria-selected="false" aria-labelledby="ui-id-3" aria-controls="tabs-2" tabindex="-1" role="tab" class="ui-state-default ui-corner-top"><a id="ui-id-3" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#contributions">Składki</a></li>
		<li aria-selected="true" aria-labelledby="ui-id-4" aria-controls="tabs-3" tabindex="0" role="tab" class="ui-state-default ui-corner-top"><a id="ui-id-4" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#news">Aktualności</a></li>
	</ul>
	<div style="display: none;" aria-hidden="true" aria-expanded="false" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-2" id="events">
           @using (Html.BeginForm("AddEvent", "Profile"))
    {
    <p>Data: <input type="text" id="datepicker" name="date" /></p>
    <p>
        Opis: <input type="text" name="opis" />
    </p>
    <p>
    Role:<br />
    <select id="role" name="role" multiple="multiple">
        @foreach (var item in Model.aspnet_Roles)
        {
            if(item.RoleName != "Administratorzy")
            {
            <option value="@item.RoleId">@item.RoleName</option>
            }
        }
    </select>
    <script type="text/javascript">
        $("#role").multiselect({
            selectedText: "# of # selected"
        });
    </script>
    </p>
    <p>
        <input type="submit" value="Dodaj" />
    </p>
    }
    @foreach (var item in Model.ActivitiesSet)
    {

            <div>
                <div style="width: 100px; float: right; position: relative;">
                &nbsp; @Html.ActionLink("Delete", "DeleteActivity", new { id = item.Id })<br />
                &nbsp; @Html.ActionLink("Edit", "EditActivity", new { id = item.Id })<br />
    
                </div>
                <div style="margin-right: 100px; height: 40px;">
                    @item.Date.ToString().Substring(0,10) :
                    @item.Description
                </div>
                <div style="clear: both" ></div>
            </div>

    }
    </div>
	<div aria-hidden="true" aria-expanded="false" style="display: none;" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-3" id="contributions"><h2>Sładki</h2>
    
    <div id="ContributionsTableContainer"></div>
<script type="text/javascript">

    $('#ContributionsTableContainer').jtable({
        title: 'Wpłaty',
        paging: true,
        pageSize: 10,
        sorting: true,
        defaultSorting: 'Amount ASC',
        actions: {
            listAction: '@Url.Action("ContributionsList")',
            deleteAction: '@Url.Action("DeleteContribution")',
            updateAction: '@Url.Action("UpdateContribution")',
            createAction: '@Url.Action("CreateContributions")'
        },
        fields: {
            COUId: {
                key: true,
                create: false,
                edit: false,
                list: false
            },
            UserId: {
                title: 'Nazwa',
                options: '@Url.Action("GetUserOptions")',
                list: true
            },
            Amount: {
                title: 'Wartość',
                create: false,
                edit: false,
                list: true
            },
            AmountId: {
                title: 'Opis',
                options: '@Url.Action("GetAmountOptions")',
                list: true
            },
            State: {
                title: 'Status',
                type: 'checkbox',
                values: { 'false': 'Niezapłacone', 'true': 'OK' },
            },
            PaymentDate: {
                title: 'Data płatności',
                type: 'date',
                create: false,
                edit: false,
                list: true
            }
        }
    });

        //Load student list from server
        $('#ContributionsTableContainer').jtable('load');

</script>
<br />

    </div>
	<div aria-hidden="false" aria-expanded="true" style="display: block;" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-4" id="news"><h2>Aktualności</h2>
    
    @using (Html.BeginForm("AddNews", "Profile"))
    {
    <p>Data: <input type="text" id="datepicker2" name="date" /></p>
    <p>
        <textarea class="mceEditor" id="elm1" name="elm1" rows="15" cols="80" style="width: 100%" runat="server"></textarea>
    </p>
    <p>
        <input type="submit" value="Dodaj" />
    </p>
    }
    @foreach (var item in Model.NewsSet)
    {

            <div>
                <div style="width: 100px; float: right; position: relative;">
                &nbsp; @Html.ActionLink("Delete", "DeleteNews", new { id = item.Id })
                </div>
                <div style="margin-right: 100px;">
                    @item.Date
                </div>

                <div style="margin-right: 100px;">
                    @HttpUtility.HtmlDecode(item.Text)
                </div>
            </div>

    }
    </div>
</div>

<script type="text/javascript">
    tinyMCE.init({
        mode: "textareas",
        editor_selector: "mceEditor",
        theme: "advanced"   //(n.b. no trailing comma, this will be critical as you experiment later)
    });
    $('#datepicker').datepicker({
        inline: true
    });
    $('#datepicker2').datepicker({
        inline: true
    });

</script>
</div>
}
else
{

<div class="col_w960_alone">
<h2>Administracja</h2>
<div class="ui-tabs ui-widget ui-widget-content ui-corner-all" id="tabs">
	<ul role="tablist" class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
		<li aria-selected="false" aria-labelledby="ui-id-2" aria-controls="tabs-1" tabindex="-1" role="tab" class="ui-state-default ui-corner-top"><a id="ui-id-2" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#events">Zajęcia i zawody</a></li>
		<li aria-selected="false" aria-labelledby="ui-id-3" aria-controls="tabs-2" tabindex="-1" role="tab" class="ui-state-default ui-corner-top"><a id="ui-id-3" tabindex="-1" role="presentation" class="ui-tabs-anchor" href="#contributions">Składki</a></li>
	</ul>
	<div style="display: none;" aria-hidden="true" aria-expanded="false" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-2" id="events">
       <h2>Wydarzenia</h2>
       
        @foreach (var item in Model.EventsInRoles)
        {
            if (Roles.IsUserInRole(Membership.GetUser().UserName, item.aspnet_Roles.RoleName))
            {
                <div>
                    @item.ActivitiesSet.Date.ToString().Substring(0, 10) :
                    @item.ActivitiesSet.Description
                </div>
            }
            
        }
    </div>
	<div aria-hidden="true" aria-expanded="false" style="display: none;" role="tabpanel" class="ui-tabs-panel ui-widget-content ui-corner-bottom" aria-labelledby="ui-id-3" id="contributions"><h2>Sładki</h2>
        
    <div id="ContributionsTableContainer"></div>
<script type="text/javascript">
    var myId = '@User.Identity.ToString()';
    $('#ContributionsTableContainer').jtable({
        title: 'Wpłaty',
        paging: true,
        pageSize: 10,
        sorting: true,
        defaultSorting: 'Amount ASC',
        actions: {
            listAction: '@Url.Action("ContributionsList")?UserId=' + myId,
        },
        fields: {
            COUId: {
                key: true,
                create: false,
                edit: false,
                list: false
            },
            UserId: {
                title: 'Nazwa',
                options: '@Url.Action("GetUserOptions")',
                list: true
            },
            Amount: {
                title: 'Wartość',
                create: false,
                edit: false,
                list: true
            },
            AmountId: {
                title: 'Opis',
                options: '@Url.Action("GetAmountOptions")',
                list: true
            },
            State: {
                title: 'Status',
                type: 'checkbox',
                values: { 'false': 'Niezapłacone', 'true': 'OK' },
            },
            PaymentDate: {
                title: 'Data płatności',
                type: 'date',
                create: false,
                edit: false,
                list: true
            }
        }
    });

        //Load student list from server
        $('#ContributionsTableContainer').jtable('load');

</script>
<br />

    </div>

</div>

</div>

}
           
<div class="cleaner"></div>